package org.example.wikwok.mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.example.wikwok.pojo.Comment;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface CommentMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(Comment record);

    int insertSelective(Comment record);

    Comment selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(Comment record);

    int updateByPrimaryKeyWithBLOBs(Comment record);

    int updateByPrimaryKey(Comment record);

    @Select("SELECT COUNT(*) FROM comment WHERE videoId = #{videoId}")
    int selectCountByVideoId(int videoId);
    @Select("SELECT * FROM comment WHERE userId = #{userId} AND videoId = #{videoId} ORDER BY id DESC")
    List<Comment> selectByUserIdAndVideoId(int userId, String videoId);

    @Delete("DELETE FROM comment WHERE videoId = #{videoId}")
    void deleteByVideoId(int videoId);

    @Select("SELECT * FROM comment WHERE videoId = #{videoId} ORDER BY id DESC")
    List<Comment> SelectByVideoId(String videoId);
}